package com.netty;

import javax.naming.ldap.SortKey;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class SocketServerDemo {

    public static void main(String[] args) throws Exception {
        //总台
        ServerSocket  serverSocket = new ServerSocket(9090);

        //等待（阻塞)
        while (true) {
            Socket socket = serverSocket.accept();

            InputStream is = socket.getInputStream();

            byte[] b = new byte[1024];
            int size = is.read(b);
            String str = new String(b, 0, size);
            System.out.println("客户端发送过来的:" + str);

            is.close();
            socket.close();
            serverSocket.close();
        }



    }
}
